@import '../../style/themes/index.less';

@switch-prefix-cls: ~'@{prefix}-switch';
@switch-min-width: 88px;
@switch-border: 2px;
@switch-small-height: 44px;
@switch-small-ball-size: 36px;

.@{switch-prefix-cls} {
  margin: 0;
  padding: 0;
  color: rgba(0, 0, 0, 0.65);
  font-size: 28px;
  list-style: none;
  font-feature-settings: 'tnum';
  position: relative;
  display: inline-block;
  box-sizing: border-box;
  min-width: @switch-min-width;
  height: @switch-small-height;
  line-height: @switch-small-height;
  vertical-align: middle;
  background-color: rgba(0, 0, 0, 0.25);
  border: @switch-border solid transparent;
  border-radius: 200px;
  cursor: pointer;
  transition: all 0.36s;
  user-select: none;
  overflow: hidden;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);

  &::before {
    content: '';
    border-color: @switch-disabled-border-color;
    border-collapse: separate;
    animation-name: none;
  }

  &:after {
    position: absolute;
    top: @switch-border;
    left: @switch-border;
    width: @switch-small-ball-size;
    height: @switch-small-ball-size;
    background-color: #fff;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.36s cubic-bezier(0.78, 0.14, 0.15, 0.86);
    content: ' ';
  }

  &-inner {
    display: block;
    margin-right: 12px;
    margin-left: 48px;
    color: #fff;
    font-size: 28px;
  }

  &-input {
    position: absolute;
    left: 0;
    z-index: 1;
    opacity: 0;
    top: 0;
    bottom: 0;
    right: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
  }

  &-checked {
    background-color: @primary-color;

    &:after {
      left: 100%;
      margin-left: -2px;
      transform: translateX(-100%);
    }

    .@{switch-prefix-cls}-inner {
      margin-right: 48px;
      margin-left: 12px;
    }
  }

  &-disabled {
    cursor: not-allowed;
    opacity: 0.4;
  }

  &-size-default {
    min-width: 100px;
    height: 54px;
    line-height: 50px;

    &:after {
      top: 3px;
      width: 44px;
      height: 44px;
    }

    .@{switch-prefix-cls}-inner {
      margin-right: 14px;
      margin-left: 60px;
    }

    &.@{switch-prefix-cls}-checked {
      &::before {
        min-width: 100px;
        height: 54px;
        line-height: 54px;
      }
      .@{switch-prefix-cls}-inner {
        margin-right: 60px;
        margin-left: 14px;
      }
    }
  }

  &-size-large {
    min-width: 120px;
    height: 64px;
    line-height: 62px;

    &:after {
      top: 4px;
      width: 52px;
      height: 52px;
    }

    .@{switch-prefix-cls}-inner {
      margin-right: 14px;
      margin-left: 70px;
      font-size: 28px;
    }

    &.@{switch-prefix-cls}-checked {
      &::before {
        min-width: 120px;
        height: 64px;
        line-height: 62px;
      }
      .@{switch-prefix-cls}-inner {
        margin-right: 60px;
        margin-left: 14px;
      }
    }
  }
}
